/**
 * @author Bastian Hinterleitner
 * created 21.11.2011 - 08:41:29
 */
// trunk
package de.Hijack.Giuliani;

import java.io.IOException;

import android.content.Context;
import android.graphics.Picture;
import android.util.Log;

import com.google.android.maps.GeoPoint;
import com.larvalabs.svgandroid.SVG;
import com.larvalabs.svgandroid.SVGParseException;
import com.larvalabs.svgandroid.SVGParser;

/**
 * a class used to display different indoor maps with a svg image
 * @author Bastian Hinterleitner
 */
public class Map {
    
    // picture
    private Picture mapPicture;
    // left upper coords
    private int longi;
    private int lati;
    // right lower coords
    private int longi2;
    private int lati2;
    
    /**
     * a new Map with an image and the geo coords where to place it
     * @param src the source image
     * @param x the latitude of the upper left corner (in GeoCoords * E6)
     * @param y the longitude of the upper left corner (in GeoCoords * E6)
     * @param x2 the latitude of the lower right corner (in GeoCoords * E6)
     * @param y2 the longitude of the lower right corner (in GeoCoords * E6)
     */
    public Map(String src, int x, int y, int x2, int y2, Context context){

        SVG svg;
        try {
                svg = SVGParser.getSVGFromAsset(context.getAssets(), src);
                mapPicture = svg.getPicture();
        } catch (SVGParseException e) {
                Log.e("Measurement", e.getMessage());
                e.printStackTrace();
                Log.e("System.err", src);
        } catch (IOException e) {
                Log.e("Measurement", e.toString());
        }
        
        lati = x;
        longi = y;
        lati2 = x2;
        longi2 = y2;
    }
    
    public GeoPoint getUpperLeftCorner(){
        return new GeoPoint(lati, longi);
    }
    
    public GeoPoint getLowerRightCorner(){
        return new GeoPoint(lati2, longi2);
    }    
    
    public Picture getPicture(){
        return mapPicture;
    }
    
    public int getWidth(){
        return lati-lati2;
    }
    
    public int getHeight(){
        return longi-longi2;
    }
}
